//
//  WmcHUD.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/8/9.
//


// TODO: - Axc: 未参与编译
// 暂时未使用

import Lottie
import UIKit
import YPBedrock

extension WmcHUDView {
    /// 单例视图
    static var sharedView: WmcHUDView = {
        let view = WmcHUDView()
        return view
    }()

    static var KeyWindow: UIWindow? {
        return YPApp.KeyWindow
    }

    static func Show() {
        guard let keyWindow = KeyWindow else { return }
        keyWindow.addSubview(sharedView)
        sharedView.frame = keyWindow.bounds
        sharedView.lottieView.play()
        // 5秒无响应自动消失
        sharedView.yp.delayLast(5) {
            Dismiss()
        }
    }

    static func Dismiss() {
        sharedView.removeFromSuperview()
        sharedView.lottieView.stop()
    }
}

// MARK: - [WmcHUDView]

class WmcHUDView: WmcBaseView {
    lazy var lottieView: LottieAnimationView = {
        let animation = LottieAnimation.named("lottie-camera-loading", bundle: .WmcBundle)
        let view = LottieAnimationView(animation: animation)
        view.backgroundColor = .white
        view.animationSpeed = 2
        view.loopMode = .autoReverse
        
        let color = UIColor.wmc_mainTheme
        return view
    }()

    override func makeUI() {
        backgroundColor = .black.yp.alpha(0.1)
        addSubview(lottieView)
        lottieView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.size.equalTo(100)
        }
    }
}
